package day6.Exer;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

public class Exer8 {
    public static void main(String[] args) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
        System.out.println("请输入您的生日（yyyy/MM/dd）");
        Scanner in = new Scanner(System.in);
        String birth = in.next();
        Date b;
        while (true) {
            try {
                 b = sdf.parse(birth);
                break;
            } catch (ParseException e) {
                System.out.println("生日格式输入错误，请重新输入");
                in.next();
            }
        }
        Calendar a=Calendar.getInstance();
        a.setTime(b);
        Calendar c=Calendar.getInstance();
        int count=0;
        while(true){
            c.add(Calendar.DAY_OF_YEAR,1);
            count++;
            if((c.get(Calendar.MONTH)==a.get(Calendar.MONTH))&&(c.get(Calendar.DAY_OF_MONTH)==a.get(Calendar.DAY_OF_MONTH))){
                break;
            }

        }
        System.out.println("距离最近的下个生日还有"+count+"天");

    }
}
